home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / samba-common.config < prev    next >
Text File  |  2008-10-10  |  2KB  |  108 lines

  1. #!/bin/sh -e
  2.  
  3. # Source debconf library.
  4. . /usr/share/debconf/confmodule
  5.  
  6. # Function for grabbing a parameter from an smb.conf file
  7. smbconf_retr() {
  8.     if [ -z "$1" ]; then
  9.         return
  10.     fi
  11.  
  12.     if [ -n "$2" ]; then
  13.         local FILE="$2"
  14.     fi
  15.  
  16.     if [ -z "$FILE" ]; then
  17.         return
  18.     fi
  19.  
  20.     sed -n -e"
  21.         s/^[[:space:]]*\[global\]/\[global\]/i
  22.         /^\[global\]/,/^[[:space:]]*\[/ {
  23.             s/^[[:space:]]*$1[[:space:]]*=[[:space:]]*//pi
  24.         }" $FILE \
  25.     | tail -n 1
  26. }
  27.  
  28. FILE=/etc/samba/smb.conf
  29.  
  30. db_title "Samba Server"
  31.  
  32. # We ask the question IFF the config contains complex options that could
  33. # cause us to break the config.
  34. if [ -f "$FILE" ] && grep -v dhcp.conf $FILE \
  35.                      | grep -qEi '\\$|^[[:space:]]*include[[:space:]]*='
  36. then
  37.     db_input high samba-common/do_debconf || true
  38.     db_go
  39. else
  40.     db_set samba-common/do_debconf true
  41. fi
  42.  
  43. # If user doesn't want to use debconf to configure Samba the leave...
  44. db_get samba-common/do_debconf || true
  45. if [ "${RET}" = "false" ]; then
  46.     exit 0
  47. fi
  48.  
  49. # User wants to use debconf, let's continue...
  50.  
  51. # Preload any values from the existing smb.conf file
  52. if [ -f $FILE ]; then
  53.     WORKGROUP=`smbconf_retr workgroup`
  54.     if [ "$WORKGROUP" ]; then
  55.         db_set samba-common/workgroup "$WORKGROUP"
  56.     fi
  57.  
  58.     ENCRYPT=`smbconf_retr "encrypt passwords"`
  59.     if [ "$ENCRYPT" ]; then
  60.         ENCRYPT=`echo $ENCRYPT | tr '[A-Z]' '[a-z]'`
  61.         if [ "$ENCRYPT" = "yes" ]; then
  62.             ENCRYPT=true
  63.         elif [ "$ENCRYPT" = "no" ]; then
  64.             ENCRYPT=false
  65.         fi
  66.  
  67.         db_set samba-common/encrypt_passwords "$ENCRYPT"
  68.     fi
  69. fi
  70.  
  71. # Get workgroup name
  72. db_input medium samba-common/workgroup || true
  73. db_go
  74.  
  75. # Use encrypted passwords?
  76. db_input medium samba-common/encrypt_passwords || true
  77. db_go
  78.  
  79. DHCPPRIORITY=medium
  80. #if [ "$DEBCONF_RECONFIGURE" = 1 ] && [ -f /sbin/dhclient3 ]
  81. #if [ -f /sbin/dhclient3 ]
  82. #then
  83. #    DHCPPRIORITY=high
  84. # TODO: see if we can detect that dhcp3-client is *going* to be installed,
  85. # even if it isn't yet.
  86. #elif dpkg-query -W --showformat='${Status}\n' dhcp3-client | grep ???
  87. # unknown ok not-installed ? 
  88. #    DHCPPRIORITY=high
  89. #fi
  90.  
  91. FOUND=false
  92. if [ -f $FILE ]; then
  93.     if grep -q 'include[[:space:]]*=[[:space:]]*/etc/samba/dhcp.conf' $FILE
  94.     then
  95.         FOUND=true
  96.     fi
  97.     db_set samba-common/dhcp $FOUND
  98. fi
  99.  
  100. # we only prompt in one of three cases: the file doesn't exist yet, it
  101. # has the context we need to add our include line, or the include line
  102. # is already present.
  103. if [ ! -f $FILE ] || grep -q -i 'wins server' $FILE || [ "$FOUND" = "true" ];
  104. then
  105.     db_input $DHCPPRIORITY samba-common/dhcp || true
  106.     db_go
  107. fi
  108.